<?php

function do_form1() {

	
	include ('fen_fns.php');
	?>
	
	<script src="scripts/main.js" type="text/javascript"></script>
	<script type="text/javascript">


var oTable;

function setForm(obj) {  

	if (obj.value == 'Makale' || obj == 'Makale' ) {
		//document.getElementById("dergi").innerHTML = "Dergi Adı:"; 

		$("#formmakale").show();
		$("#formsayfa").show();
		$("#formkitapadi").hide();
		$("#formeditoradi").hide();
		$("#formisbn").hide();
		
	} else if (obj.value == 'Kitap Bölümü' || obj == 'Kitap Bölümü' ) {

		$("#formmakale").hide();
		$("#formkitapadi").show();
		$("#formeditoradi").show();
		$("#formisbn").show();

	} else if (obj.value == 'Kitap' || obj == 'Kitap' ) {

		$("#formmakale").hide();
		$("#formdergiadi").hide();
		$("#formkitapadi").hide();
		$("#formeditoradi").show();
		$("#formisbn").show();

	}
    return false;  
} 

function setDoiweb(obj) {  

	if (obj.value == 'doi') {
		//document.getElementById("dergi").innerHTML = "Dergi Adı:"; 

		$("#formdoihead").show();
		$("#formdoi").show();
		$("#formwebhead").hide();
		
	} else if (obj.value == 'web' ) {

		$("#formwebhead").show();
		$("#formdoi").show();
		$("#formdoihead").hide();

	} else {
		$("#formdoihead").hide();
		$("#formdoi").hide();
		$("#formwebhead").hide();
	}
    return false;  
} 

function setIndeksAlan(obj) {  

	if (obj.value == 'Alan') {
		//document.getElementById("dergi").innerHTML = "Dergi Adı:"; 

		$("#indeks_alan_div").show();
		
	} else {
		$("#indeks_alan_div").hide();
	}
    return false;  
} 

$(document).ready(function() {
    /* Add a click handler to the rows - this could be used as a callback */ 

	$('.toggle1').hide();

	$("#indeks_alan_div").hide();

    $(".contentTopArea").hide();

    $('.buttonAdd').click(function(){
    	$(".contentTopArea").slideToggle(150);
    	//$(".contentTopArea").load("forms/form1.php");

    	$(".contentTopArea").load("forms/form1.php", function(){
    		$("#formmakale").show();
    		$("#formsayfa").show();
    		$("#formkitapadi").hide();
    		$("#formeditoradi").hide();
    		$("#formisbn").hide();
    		$("#formdoihead").hide();
    		$("#formwebhead").hide();
    		$("#formdoi").hide();
        });
    });

    $('.buttonClose').click(function(){
        $(".contentTopArea").slideToggle(150);
    });    

	oTable = $('#example').dataTable({
        "sPaginationType": "full_numbers",
		"sDom": 'f<"toolbar">t<lip><"clear">'
	});

	
	$("div.toolbar").html('<input type=\"submit\" id=\"buttonModify\" value=\"Güncelle\" />  <input type=\"submit\" id=\"buttonDelete\" value=\"Sil\" /> <input type=\"submit\" id=\"buttonPDF\" value=\"PDF\" />');

	$(":input").bind("click keypress", function(evt) {
        var keyCode = evt.which || evt.keyCode;

			var sender = evt.target;
			if (sender.id == 'buttonModify') {

				$(".contentTopArea").hide();
				var sDataOne = oTable.$('input:checkbox:checked').val();
				var sData = oTable.$('input:checkbox:checked').serialize();

				
				if (sData.length == '0') {
					alert("Lütfen güncellemek istediğiniz kaydı seçiniz");
					return false;
				} else if (sData.length < 20) {

					if (sData.search("B") != '-1') {
						$(".contentTopArea").load("forms/form1.php?uid="+sDataOne, function(){
							$("#formmakale").hide(); $("#formdergiadi").hide(); $("#formkitapadi").hide(); $("#formisbn").show(); });
					}

					if (sData.search("C") != '-1') {
						$(".contentTopArea").load("forms/form1.php?uid="+sDataOne, function(){
							$("#formmakale").show(); $("#formsayfa").show(); $("#formkitapadi").hide(); $("#formisbn").hide(); $("#formeditoradi").hide(); });
					}

					if (sData.search("A") != '-1') {
						$(".contentTopArea").load("forms/form1.php?uid="+sDataOne, function(){
							$("#formmakale").hide(); $("#formkitapadi").show(); $("#formisbn").show(); });
					}
			        
			        $(".contentTopArea").slideToggle(150);
					return false;
									
				} else {
					alert("Aynı anda sadece tek bir kayıt güncellenebilir.");
					return false;	
				}
			} else if (sender.id == 'buttonDelete') {

				var sData = oTable.$('input:checkbox:checked').serialize();
				if (sData.length == '0') {
					alert("Lütfen silmek istediğiniz kaydı seçiniz");
					return false;
				} else if (confirm('Seçmiş olduğunuz kayıt silinecektir. Onaylıyor musunuz?')){
				$.ajax({
					type:'POST',
					url:'delete.php',
					data:oTable.$('input:checkbox:checked').serialize(),
					success:function(cevap){
					    $("#sonuc").html(cevap);
						$('body').load('form.php?fid=2');
					 	return false;
					}})

				return false;
				} else {
					return false;
				}
			} else if (sender.id == 'buttonPDF') {

				var sDataOne = oTable.$('input:checkbox:checked').val();
				var sData = oTable.$('input:checkbox:checked').serialize();


				if (sData.length == '0') {
					alert("Lütfen PDF'ini almak istediğiniz kaydı seçiniz");
					return false;
				} else if (sData.length < 20) {

					window.open('forms/form1_pdf.php?pid='+sDataOne, '_self');
					return false;
									
				} else {
					alert("Aynı anda sadece tek bir kayıt için PDF oluşturulur.");
					return false;	
				}
			}

        return true;
    });
} );

tooltip();

function showUser(obj) {  

	jQuery(document).ready(function($) {
		  $('a[rel*=facebox]').facebox() 

		  jQuery.facebox({ ajax: 'forms/transaction-history.php?pid='+obj })
	}) 
} 


</script>	
	

	<div class="contentTop">
		<div class="contentTopArea">
			<div id="formdiv"></div>
		</div>
	</div>
	<div class="contentMain">
		
		<br><br><button class="buttonAdd" id="buttonAdd" type="button">Yayın Ekle</button><br><br><br>
		
	</div>
	<div class="showtable">

			<form id="form">
				<table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
						<thead>
							<tr>
								<th id="left"></th>
								<th>Yayın Tipi</th>
								<th>Yayın türü</th>
								<th>Eser Adı</th>
								<th>Dergi Adı</th>
								<th>Volume / Issue</th>
								<th>Yayınevi Adı</th>
								<th>Yayın Yılı</th>
								<th>Yazar Sayısı</th>
								<th>İndeks</th>
								<th>Teşvik Durumu</th>
								<th>İşlem Tarihçesi</th>
							</tr>
						</thead>
						<tbody>
						
<?php 

						
						$query = $_DB->Query("SELECT * from fen_publications WHERE member_id = '".$_SESSION['user_id']."' ORDER BY id DESC");
						$count = $_DB->GetResultNumber($query);

						for ($i=0; $i<$count; $i++)
						{
							
							if ($_DB->GetResultValue($query, $i, "yayin_tipi") == 'Kitap Bölümü') {
								$yayin_tipi_kod = "A";
							} else if ($_DB->GetResultValue($query, $i, "yayin_tipi") == 'Kitap') {
								$yayin_tipi_kod = "B";
							} else {
								$yayin_tipi_kod = "C";
							}
							
							if ($_DB->GetResultValue($query, $i, "volume") && $_DB->GetResultValue($query, $i, "issue")) {
								$volumeissue = $_DB->GetResultValue($query, $i, "volume")." (".$_DB->GetResultValue($query, $i, "issue").")";
							} else if ($_DB->GetResultValue($query, $i, "volume") && !$_DB->GetResultValue($query, $i, "issue")) {
							    $volumeissue = $_DB->GetResultValue($query, $i, "volume");
						     } else {
								$volumeissue = "-";
							}
							
							if ($_DB->GetResultValue($query, $i, "sinif")) {
								$sinif = "<br>(".$_DB->GetResultValue($query, $i, "sinif").")";
							} else {
								$sinif = "";
							}
							
							$querystatus = $_DB->Query("SELECT status, cancel_reason from fen_publication_app WHERE publication_id = '".$_DB->GetResultValue($query, $i, "id")."'");
							$statustest = $_DB->GetResultValue($querystatus, "0", "status");

							if ($statustest == '0') {
								$status = "<a class=\"tooltip\" title=\"".$_DB->GetResultValue($querystatus, "0", "cancel_reason")."\"><font color=\"#dd0303\">Reddedildi</font><img src=\"images/reasonicon.gif\"></img></a>";
							} else if ($statustest == '2') {
								$status = "<font color=\"#f97b00\">Yeni</font>";
							} else if ($statustest == '3') {
								$status = "<font color=\"#539e3b\">Rektörlüğe Gönderildi</font>";
							} else if ($statustest == '4') {		
								$status = "<font color=\"#8066a0\">Mali İşlere Gönderildi.&nbsp;&nbsp;</font>";
							} else if ($statustest == '5') {
								$queryamount = $_DB->Query("SELECT amount, date_FORMAT(date_added , '%d/%m/%Y') as date_added from fen_payments where publication_id = '".$_DB->GetResultValue($query, $i, "id")."'");
								$status = "<a class=\"tooltip\" title=\"".$_DB->GetResultValue($queryamount, "0", "date_added")." tarihinde<br> ".$_DB->GetResultValue($queryamount, "0", "amount")." TL ödendi.\"><font color=\"#35aed5\">Ödeme Yapıldı.</font><img src=\"images/reasonicon.gif\"></img></a>";
							} else {
								$status = "Başvurulmadı";
							}
	
							
							echo "
								<tr>
									<td class=\"left\"><input id=\"showtableCheckBox\" type=\"checkbox\" name=\"check".$_DB->GetResultValue($query, $i, "id")."\" value=\"".$yayin_tipi_kod."-".$_DB->GetResultValue($query, $i, "id")."\"></td>
									<td>".$_DB->GetResultValue($query, $i, "yayin_tipi")."</td>
									<td>".$_DB->GetResultValue($query, $i, "yayin_turu")."</td>
									<td>".$_DB->GetResultValue($query, $i, "eser_adi")."</td>
									<td>".$_DB->GetResultValue($query, $i, "dergi_adi")."</td>
									<td class=\"center\">".$volumeissue."</td>
									<td>".$_DB->GetResultValue($query, $i, "yayinevi_adi")."</td>
									<td class=\"center\">".$_DB->GetResultValue($query, $i, "yayin_yili")."</td>
									<td class=\"center\">".$_DB->GetResultValue($query, $i, "yazar_sayisi")."</td>
									<td class=\"center\">".$_DB->GetResultValue($query, $i, "indeks_turu")." ".$sinif."</td>
									<td>".$status."</td>
			        				<td class=\"center\"><a class =\"user_detail_but\" onclick=\"showUser('".$_DB->GetResultValue($query, $i, "id")."')\" href=\"#\"><img id=\"editimg\" src=\"images/transactionhistory.gif\"></img></a></td>
								</tr>";		
						}
							


?>

						</tbody>
					</table>
					<br>
					<font color="#61bdf4">*</font> Rektörlükçe işleme alınmış yayınlar için silme işlemi <u>yapılamaz!</u>
				</form>

			</div>
	</div>




<?php

}

function do_form2() {


	include ('fen_fns.php');
	?>
	
	<script type="text/javascript">

	

	function setForm(obj) {  

		if (obj.value == 'Evet') {
			//document.getElementById("dergi").innerHTML = "Dergi Adı:"; 

			$("#sorumlu_ders").show();
			
		} else if (obj.value == 'Hayır' ) {

			$("#sorumlu_ders").hide();

		} 
	    //return false;  
	} 

	function setForm2(obj) {  

		if (obj.value == 'Evet') {
			//document.getElementById("dergi").innerHTML = "Dergi Adı:"; 

			$("#baska_destek_div").show();
			
		} else if (obj.value == 'Hayır' ) {

			$("#baska_destek_div").hide();

		} 
	    //return false;  
	} 

	function setForm3(obj, i) {  

		if (obj.value == 'Kendim') {
			//document.getElementById("dergi").innerHTML = "Dergi Adı:"; 

			if (i == 0) {
				$("#kendim").show();
				$("#diger").hide();
				$('#diger').find('input:text').val(''); 
			} else if (i == 1) {
				$("#kendim1").show();
				$("#diger1").hide();
				$('#diger1').find('input:text').val(''); 
			} else if (i == 2) {
				$("#kendim2").show();
				$("#diger2").hide();
				$('#diger2').find('input:text').val(''); 
			} else if (i == 3) {
				$("#kendim3").show();
				$("#diger3").hide();
				$('#diger3').find('input:text').val(''); 
			}
			
		} else if (obj.value == 'Diger' ) {

			if (i == 0) {
				$("#kendim").hide();
				$('#kendim').find('input:text').val(''); 
				$("#diger").show();
			} else if (i == 1) {
				$("#kendim1").hide();
				$('#kendim1').find('input:text').val(''); 
				$("#diger1").show();
			} else if (i == 2) {
				$("#kendim2").hide();
				$('#kendim2').find('input:text').val(''); 
				$("#diger2").show();
			} else if (i == 3) {
				$("#kendim3").hide();
				$('#kendim3').find('input:text').val(''); 
				$("#diger3").show();
			} 
		} 
 
	} 


        

var oTable;

	$(document).ready(function() {
    /* Add a click handler to the rows - this could be used as a callback */ 

	
	

    $("#sorumlu_ders").hide();

	$('.toggle1').hide();

    $(".contentTopArea").hide();

    $('.buttonAdd').click(function(){
    	$(".contentTopArea").slideToggle(150);

    	$(".contentTopArea").load("forms/form2.php", function(){
    		$("#formmakale").show();
    		$("#formsayfa").show();
    		$("#formkitapadi").hide();
    		$("#formisbn").hide();
        });
    });

    $('.buttonClose').click(function(){
        $(".contentTopArea").slideToggle(150);
    });    

	oTable = $('#example').dataTable({
        "sPaginationType": "full_numbers",
		"sDom": 'f<"toolbar">t<lip><"clear">'
	});

	
	$("div.toolbar").html('<input type=\"submit\" id=\"buttonModify\" value=\"Güncelle\" />  <input type=\"submit\" id=\"buttonDelete\" value=\"Sil\" /> <input type=\"submit\" id=\"buttonPDF\" value=\"PDF\" />');

	$(":input").bind("click keypress", function(evt) {
        var keyCode = evt.which || evt.keyCode;

			var sender = evt.target;
			if (sender.id == 'buttonModify') {

				$(".contentTopArea").hide();
				var sDataOne = oTable.$('input:checkbox:checked').val();
				var sData = oTable.$('input:checkbox:checked').serialize();

				
				if (sData.length == '0') {
					alert("Lütfen güncellemek istediğiniz kaydı seçiniz");
					return false;
				} else if (sData.length < 20) {

					$(".contentTopArea").load("forms/form2.php?uid="+sDataOne);
					$(".contentTopArea").slideToggle(150);
					return false;
									
				} else {
					alert("Aynı anda sadece tek bir kayıt güncellenebilir.");
					return false;	
				}
			} else if (sender.id == 'buttonDelete') {

				var sData = oTable.$('input:checkbox:checked').serialize();
				if (sData.length == '0') {
					alert("Lütfen silmek istediğiniz kaydı seçiniz");
					return false;
				} else if (confirm('Seçmiş olduğunuz kayıt silinecektir. Onaylıyor musunuz?')){
				$.ajax({
					type:'POST',
					url:'forms/form2delete.php',
					data:oTable.$('input:checkbox:checked').serialize(),
					success:function(cevap){
					    $("#sonuc").html(cevap);
						$('body').load('form.php?fid=1');
					 	return false;
					}})

				return false;
				} else {
					return false;
				}
			} else if (sender.id == 'buttonPDF') {

				var sDataOne = oTable.$('input:checkbox:checked').val();
				var sData = oTable.$('input:checkbox:checked').serialize();


				if (sData.length == '0') {
					alert("Lütfen PDF'ini almak istediğiniz kaydı seçiniz");
					return false;
				} else if (sData.length < 20) {

					window.open('forms/form2_pdf.php?pid='+sDataOne, '_self');
					return false;
									
				} else {
					alert("Aynı anda sadece tek bir kayıt için PDF oluşturulur.");
					return false;	
				}
			}

        return true;
    });
} );

	$(function() {
	    $( "#from" ).datepicker({
	      defaultDate: "+1w",
	      changeMonth: true,
	      numberOfMonths: 3,
	      onClose: function( selectedDate ) {
	        $( "#to" ).datepicker( "option", "minDate", selectedDate );
	      }
	    });
	    $( "#to" ).datepicker({
	      defaultDate: "+1w",
	      changeMonth: true,
	      numberOfMonths: 3,
	      onClose: function( selectedDate ) {
	        $( "#from" ).datepicker( "option", "maxDate", selectedDate );
	      }
	    });
	  });

</script>	
	
	<div class="contentTop">
		<div class="contentTopArea">
			<div id="formdiv"></div>
		</div>
	</div>
	<div class="contentMain">
		
		<br><br><button class="buttonAdd" id="buttonAdd" type="button">Toplantı Ekle</button><br><br><br>
		
	</div>
	<div class="showtable">

			<form id="form">
				<table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
						<thead>
							<tr>
								<th id="left"></th>
								<th>Toplantı Adı</th>
								<th>Bildiri Konusu</th>
								<th>Ülke</th>
								<th>Şehir</th>
								<th>Toplantı<br>Başlangıç</th>
								<th>Toplantı<br>Bitiş</th>
								<th>Talep Nedeni</th>
								<th>Destek Türü</th>
								<th>İstenen<br>Tutar</th>
								<th>BAU'nun<br>Ödediği Tutar</th>
							</tr>
						</thead>
						<tbody>
						
<?php 


						$query = $_DB->Query("SELECT *, date_FORMAT(tarih1, '%d/%m/%Y') as tarih_baslangic, date_FORMAT(tarih2, '%d/%m/%Y') as tarih_bitis from fen_toplanti WHERE member_id = '".$_SESSION['user_id']."' ORDER BY tarih1 DESC");
						$count = $_DB->GetResultNumber($query);
						
						$date = date("d F Y",strtotime($myrow['date']));
						
						

						for ($i=0; $i<$count; $i++)
						{
							
							$sebep = array();
							$sebepfinal = "";

							$talep_sebebi1 = "";
							$talep_sebebi2 = "";
							$talep_sebebi3 = "";						
							
							if ($_DB->GetResultValue($query, $i, "talep_sebebi1") == '1') { array_push($sebep, "Yol"); }						
							if ($_DB->GetResultValue($query, $i, "talep_sebebi2") == '1') { array_push($sebep, "Kayıt"); }				
							if ($_DB->GetResultValue($query, $i, "talep_sebebi3") == '1') { array_push($sebep, "Harcırah"); }
							
							for ($x = 0; $x < count($sebep); $x++)
							{
							$sebepfinal .= $sebep[$x];  // The current element
								if ($x != count($sebep)-1) {
									$sebepfinal .= ", ";
								} 
							}
							
							if ($_DB->GetResultValue($query, $i, "odenen_tutar") > 0) {
								$odenen = $_DB->GetResultValue($query, $i, "odenen_tutar")." ".$_DB->GetResultValue($query, $i, "para_birimi");
							} else {
								$odenen = "Henüz ödenmedi";
							}
							
							echo "
								<tr>
									<td class=\"left\"><input id=\"showtableCheckBox\" type=\"checkbox\" name=\"check".$_DB->GetResultValue($query, $i, "id")."\" value=\"".$yayin_tipi_kod."-".$_DB->GetResultValue($query, $i, "id")."\"></td>
									<td>".$_DB->GetResultValue($query, $i, "toplanti_adi")."</td>
									<td>".$_DB->GetResultValue($query, $i, "bildiri_konusu")."</td>
									<td>".$_DB->GetResultValue($query, $i, "ulke")."</td>
									<td>".$_DB->GetResultValue($query, $i, "sehir")."</td>
									<td class=\"center\">".$_DB->GetResultValue($query, $i, "tarih_baslangic")."</td>
									<td class=\"center\">".$_DB->GetResultValue($query, $i, "tarih_bitis")."</td>
									<td class=\"center\">".$sebepfinal."</td>
									<td class=\"center\">".$_DB->GetResultValue($query, $i, "destek_turu")."</td>
									<td class=\"center\">".$_DB->GetResultValue($query, $i, "tutar")." ".$_DB->GetResultValue($query, $i, "para_birimi")."</td>
									<td class=\"center\">".$odenen."</td>
								</tr>";		
						}
							
?>

						</tbody>
					</table>
					<br>
					<font color="#61bdf4">*</font> Lütfen BAU tarafından ödenen net tutarı toplantı dönüşü <u>güncelleyiniz!</u>
					
				</form>

			</div>
	</div>




<?php
}